home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / perl / dist / x2p / s2p.SH < prev    next >
Encoding:
Text File  |  1991-06-10  |  13.9 KB  |  766 lines

  1. : This forces SH files to create target in same directory as SH file.
  2. : This is so that make depend always knows where to find SH derivatives.
  3. case "$0" in
  4. */*) cd `expr X$0 : 'X\(.*\)/'` ;;
  5. esac
  6. case $CONFIG in
  7. '')
  8.     if test ! -f config.sh; then
  9.     ln ../config.sh . || \
  10.     ln -s ../config.sh . || \
  11.     ln ../../config.sh . || \
  12.     ln ../../../config.sh . || \
  13.     (echo "Can't find config.sh."; exit 1)
  14.     fi 2>/dev/null
  15.     . ./config.sh
  16.     ;;
  17. esac
  18. echo "Extracting s2p (with variable substitutions)"
  19. : This section of the file will have variable substitutions done on it.
  20. : Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
  21. : Protect any dollar signs and backticks that you do not want interpreted
  22. : by putting a backslash in front.  You may delete these comments.
  23. $spitshell >s2p <<!GROK!THIS!
  24. #!$bin/perl
  25.  
  26. \$bin = '$bin';
  27. !GROK!THIS!
  28.  
  29. : In the following dollars and backticks do not need the extra backslash.
  30. $spitshell >>s2p <<'!NO!SUBS!'
  31.  
  32. # $RCSfile: s2p.SH,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:19:18 $
  33. #
  34. # $Log:    s2p.SH,v $
  35. # Revision 4.0.1.1  91/06/07  12:19:18  lwall
  36. # patch4: s2p now handles embedded newlines better and optimizes common idioms
  37. # Revision 4.0  91/03/20  01:57:59  lwall
  38. # 4.0 baseline.
  39. #
  40.  
  41. $indent = 4;
  42. $shiftwidth = 4;
  43. $l = '{'; $r = '}';
  44.  
  45. while ($ARGV[0] =~ /^-/) {
  46.     $_ = shift;
  47.   last if /^--/;
  48.     if (/^-D/) {
  49.     $debug++;
  50.     open(BODY,'>-');
  51.     next;
  52.     }
  53.     if (/^-n/) {
  54.     $assumen++;
  55.     next;
  56.     }
  57.     if (/^-p/) {
  58.     $assumep++;
  59.     next;
  60.     }
  61.     die "I don't recognize this switch: $_\n";
  62. }
  63.  
  64. unless ($debug) {
  65.     open(BODY,">/tmp/sperl$$") ||
  66.       &Die("Can't open temp file: $!\n");
  67. }
  68.  
  69. if (!$assumen && !$assumep) {
  70.     print BODY &q(<<'EOT');
  71. :    while ($ARGV[0] =~ /^-/) {
  72. :        $_ = shift;
  73. :      last if /^--/;
  74. :        if (/^-n/) {
  75. :        $nflag++;
  76. :        next;
  77. :        }
  78. :        die "I don't recognize this switch: $_\\n";
  79. :    }
  80. :    
  81. EOT
  82. }
  83.  
  84. print BODY &q(<<'EOT');
  85. :    #ifdef PRINTIT
  86. :    #ifdef ASSUMEP
  87. :    $printit++;
  88. :    #else
  89. :    $printit++ unless $nflag;
  90. :    #endif
  91. :    #endif
  92. :    <><>
  93. :    $\ = "\n";        # automatically add newline on print
  94. :    <><>
  95. :    #ifdef TOPLABEL
  96. :    LINE:
  97. :    while (chop($_ = <>)) {
  98. :    #else
  99. :    LINE:
  100. :    while (<>) {
  101. :        chop;
  102. :    #endif
  103. EOT
  104.  
  105. LINE:
  106. while (<>) {
  107.  
  108.     # Wipe out surrounding whitespace.
  109.  
  110.     s/[ \t]*(.*)\n$/$1/;
  111.  
  112.     # Perhaps it's a label/comment.
  113.  
  114.     if (/^:/) {
  115.     s/^:[ \t]*//;
  116.     $label = &make_label($_);
  117.     if ($. == 1) {
  118.         $toplabel = $label;
  119.         if (/^(top|(re)?start|redo|begin(ning)|again|input)$/i) {
  120.         $_ = <>;
  121.         redo LINE; # Never referenced, so delete it if not a comment.
  122.         }
  123.     }
  124.     $_ = "$label:";
  125.     if ($lastlinewaslabel++) {
  126.         $indent += 4;
  127.         print BODY &tab, ";\n";
  128.         $indent -= 4;
  129.     }
  130.     if ($indent >= 2) {
  131.         $indent -= 2;
  132.         $indmod = 2;
  133.     }
  134.     next;
  135.     } else {
  136.     $lastlinewaslabel = '';
  137.     }
  138.  
  139.     # Look for one or two address clauses
  140.  
  141.     $addr1 = '';
  142.     $addr2 = '';
  143.     if (s/^([0-9]+)//) {
  144.     $addr1 = "$1";
  145.     $addr1 = "\$. == $addr1" unless /^,/;
  146.     }
  147.     elsif (s/^\$//) {
  148.     $addr1 = 'eof()';
  149.     }
  150.     elsif (s|^/||) {
  151.     $addr1 = &fetchpat('/');
  152.     }
  153.     if (s/^,//) {
  154.     if (s/^([0-9]+)//) {
  155.         $addr2 = "$1";
  156.     } elsif (s/^\$//) {
  157.         $addr2 = "eof()";
  158.     } elsif (s|^/||) {
  159.         $addr2 = &fetchpat('/');
  160.     } else {
  161.         &Die("Invalid second address at line $.\n");
  162.     }
  163.     $addr1 .= " .. $addr2";
  164.     }
  165.  
  166.     # Now we check for metacommands {, }, and ! and worry
  167.     # about indentation.
  168.  
  169.     s/^[ \t]+//;
  170.     # a { to keep vi happy
  171.     if ($_ eq '}') {
  172.     $indent -= 4;
  173.     next;
  174.     }
  175.     if (s/^!//) {
  176.     $if = 'unless';
  177.     $else = "$r else $l\n";
  178.     } else {
  179.     $if = 'if';
  180.     $else = '';
  181.     }
  182.     if (s/^{//) {    # a } to keep vi happy
  183.     $indmod = 4;
  184.     $redo = $_;
  185.     $_ = '';
  186.     $rmaybe = '';
  187.     } else {
  188.     $rmaybe = "\n$r";
  189.     if ($addr2 || $addr1) {
  190.         $space = ' ' x $shiftwidth;
  191.     } else {
  192.         $space = '';
  193.     }
  194.     $_ = &transmogrify();
  195.     }
  196.  
  197.     # See if we can optimize to modifier form.
  198.  
  199.     if ($addr1) {
  200.     if ($_ !~ /[\n{}]/ && $rmaybe && !$change &&
  201.       $_ !~ / if / && $_ !~ / unless /) {
  202.         s/;$/ $if $addr1;/;
  203.         $_ = substr($_,$shiftwidth,1000);
  204.     } else {
  205.         $_ = "$if ($addr1) $l\n$change$_$rmaybe";
  206.     }
  207.     $change = '';
  208.     next LINE;
  209.     }
  210. } continue {
  211.     @lines = split(/\n/,$_);
  212.     for (@lines) {
  213.     unless (s/^ *<<--//) {
  214.         print BODY &tab;
  215.     }
  216.     print BODY $_, "\n";
  217.     }
  218.     $indent += $indmod;
  219.     $indmod = 0;
  220.     if ($redo) {
  221.     $_ = $redo;
  222.     $redo = '';
  223.     redo LINE;
  224.     }
  225. }
  226. if ($lastlinewaslabel++) {
  227.     $indent += 4;
  228.     print BODY &tab, ";\n";
  229.     $indent -= 4;
  230. }
  231.  
  232. if ($appendseen || $tseen || !$assumen) {
  233.     $printit++ if $dseen || (!$assumen && !$assumep);
  234.     print BODY &q(<<'EOT');
  235. :    #ifdef SAWNEXT
  236. :    }
  237. :    continue {
  238. :    #endif
  239. :    #ifdef PRINTIT
  240. :    #ifdef DSEEN
  241. :    #ifdef ASSUMEP
  242. :        print if $printit++;
  243. :    #else
  244. :        if ($printit)
  245. :        { print; }
  246. :        else
  247. :        { $printit++ unless $nflag; }
  248. :    #endif
  249. :    #else
  250. :        print if $printit;
  251. :    #endif
  252. :    #else
  253. :        print;
  254. :    #endif
  255. :    #ifdef TSEEN
  256. :        $tflag = 0;
  257. :    #endif
  258. :    #ifdef APPENDSEEN
  259. :        if ($atext) { chop $atext; print $atext; $atext = ''; }
  260. :    #endif
  261. EOT
  262.  
  263. print BODY &q(<<'EOT');
  264. :    }
  265. EOT
  266. }
  267.  
  268. close BODY;
  269.  
  270. unless ($debug) {
  271.     open(HEAD,">/tmp/sperl2$$.c")
  272.       || &Die("Can't open temp file 2: $!\n");
  273.     print HEAD "#define PRINTIT\n"    if $printit;
  274.     print HEAD "#define APPENDSEEN\n"    if $appendseen;
  275.     print HEAD "#define TSEEN\n"    if $tseen;
  276.     print HEAD "#define DSEEN\n"    if $dseen;
  277.     print HEAD "#define ASSUMEN\n"    if $assumen;
  278.     print HEAD "#define ASSUMEP\n"    if $assumep;
  279.     print HEAD "#define TOPLABEL\n"    if $toplabel;
  280.     print HEAD "#define SAWNEXT\n"    if $sawnext;
  281.     if ($opens) {print HEAD "$opens\n";}
  282.     open(BODY,"/tmp/sperl$$")
  283.       || &Die("Can't reopen temp file: $!\n");
  284.     while (<BODY>) {
  285.     print HEAD $_;
  286.     }
  287.     close HEAD;
  288.  
  289.     print &q(<<"EOT");
  290. :    #!$bin/perl
  291. :    eval 'exec $bin/perl -S \$0 \${1+"\$@"}'
  292. :        if \$running_under_some_shell;
  293. :    
  294. EOT
  295.     open(BODY,"cc -E /tmp/sperl2$$.c |") ||
  296.     &Die("Can't reopen temp file: $!\n");
  297.     while (<BODY>) {
  298.     /^# [0-9]/ && next;
  299.     /^[ \t]*$/ && next;
  300.     s/^<><>//;
  301.     print;
  302.     }
  303. }
  304.  
  305. &Cleanup;
  306. exit;
  307.  
  308. sub Cleanup {
  309.     chdir "/tmp";
  310.     unlink "sperl$$", "sperl2$$", "sperl2$$.c";
  311. }
  312. sub Die {
  313.     &Cleanup;
  314.     die $_[0];
  315. }
  316. sub tab {
  317.     "\t" x ($indent / 8) . ' ' x ($indent % 8);
  318. }
  319. sub make_filehandle {
  320.     local($_) = $_[0];
  321.     local($fname) = $_;
  322.     if (!$seen{$fname}) {
  323.     $_ = "FH_" . $_ if /^\d/;
  324.     s/[^a-zA-Z0-9]/_/g;
  325.     s/^_*//;
  326.     $_ = "\U$_";
  327.     if ($fhseen{$_}) {
  328.         for ($tmp = "a"; $fhseen{"$_$tmp"}; $a++) {}
  329.         $_ .= $tmp;
  330.     }
  331.     $fhseen{$_} = 1;
  332.     $opens .= &q(<<"EOT");
  333. :    open($_, '>$fname') || die "Can't create $fname: \$!";
  334. EOT
  335.     $seen{$fname} = $_;
  336.     }
  337.     $seen{$fname};
  338. }
  339.  
  340. sub make_label {
  341.     local($label) = @_;
  342.     $label =~ s/[^a-zA-Z0-9]/_/g;
  343.     if ($label =~ /^[0-9_]/) { $label = 'L' . $label; }
  344.     $label = substr($label,0,8);
  345.  
  346.     # Could be a reserved word, so capitalize it.
  347.     substr($label,0,1) =~ y/a-z/A-Z/
  348.       if $label =~ /^[a-z]/;
  349.  
  350.     $label;
  351. }
  352.  
  353. sub transmogrify {
  354.     {    # case
  355.     if (/^d/) {
  356.         $dseen++;
  357.         chop($_ = &q(<<'EOT'));
  358. :    <<--#ifdef PRINTIT
  359. :    $printit = 0;
  360. :    <<--#endif
  361. :    next LINE;
  362. EOT
  363.         $sawnext++;
  364.         next;
  365.     }
  366.  
  367.     if (/^n/) {
  368.         chop($_ = &q(<<'EOT'));
  369. :    <<--#ifdef PRINTIT
  370. :    <<--#ifdef DSEEN
  371. :    <<--#ifdef ASSUMEP
  372. :    print if $printit++;
  373. :    <<--#else
  374. :    if ($printit)
  375. :        { print; }
  376. :    else
  377. :        { $printit++ unless $nflag; }
  378. :    <<--#endif
  379. :    <<--#else
  380. :    print if $printit;
  381. :    <<--#endif
  382. :    <<--#else
  383. :    print;
  384. :    <<--#endif
  385. :    <<--#ifdef APPENDSEEN
  386. :    if ($atext) {chop $atext; print $atext; $atext = '';}
  387. :    <<--#endif
  388. :    $_ = <>;
  389. :    chop;
  390. :    <<--#ifdef TSEEN
  391. :    $tflag = 0;
  392. :    <<--#endif
  393. EOT
  394.         next;
  395.     }
  396.  
  397.     if (/^a/) {
  398.         $appendseen++;
  399.         $command = $space . "\$atext .= <<'End_Of_Text';\n<<--";
  400.         $lastline = 0;
  401.         while (<>) {
  402.         s/^[ \t]*//;
  403.         s/^[\\]//;
  404.         unless (s|\\$||) { $lastline = 1;}
  405.         s/^([ \t]*\n)/<><>$1/;
  406.         $command .= $_;
  407.         $command .= '<<--';
  408.         last if $lastline;
  409.         }
  410.         $_ = $command . "End_Of_Text";
  411.         last;
  412.     }
  413.  
  414.     if (/^[ic]/) {
  415.         if (/^c/) { $change = 1; }
  416.         $addr1 = 1 if $addr1 eq '';
  417.         $addr1 = '$iter = (' . $addr1 . ')';
  418.         $command = $space .
  419.           "    if (\$iter == 1) { print <<'End_Of_Text'; }\n<<--";
  420.         $lastline = 0;
  421.         while (<>) {
  422.         s/^[ \t]*//;
  423.         s/^[\\]//;
  424.         unless (s/\\$//) { $lastline = 1;}
  425.         s/'/\\'/g;
  426.         s/^([ \t]*\n)/<><>$1/;
  427.         $command .= $_;
  428.         $command .= '<<--';
  429.         last if $lastline;
  430.         }
  431.         $_ = $command . "End_Of_Text";
  432.         if ($change) {
  433.         $dseen++;
  434.         $change = "$_\n";
  435.         chop($_ = &q(<<"EOT"));
  436. :    <<--#ifdef PRINTIT
  437. :    $space\$printit = 0;
  438. :    <<--#endif
  439. :    ${space}next LINE;
  440. EOT
  441.         $sawnext++;
  442.         }
  443.         last;
  444.     }
  445.  
  446.     if (/^s/) {
  447.         $delim = substr($_,1,1);
  448.         $len = length($_);
  449.         $repl = $end = 0;
  450.         $inbracket = 0;
  451.         for ($i = 2; $i < $len; $i++) {
  452.         $c = substr($_,$i,1);
  453.         if ($c eq $delim) {
  454.             if ($inbracket) {
  455.             substr($_, $i, 0) = '\\';
  456.             $i++;
  457.             $len++;
  458.             }
  459.             else {
  460.             if ($repl) {
  461.                 $end = $i;
  462.                 last;
  463.             } else {
  464.                 $repl = $i;
  465.             }
  466.             }
  467.         }
  468.         elsif ($c eq '\\') {
  469.             $i++;
  470.             if ($i >= $len) {
  471.             $_ .= 'n';
  472.             $_ .= <>;
  473.             $len = length($_);
  474.             $_ = substr($_,0,--$len);
  475.             }
  476.             elsif (substr($_,$i,1) =~ /^[n]$/) {
  477.             ;
  478.             }
  479.             elsif (!$repl &&
  480.               substr($_,$i,1) =~ /^[(){}\w]$/) {
  481.             $i--;
  482.             $len--;
  483.             substr($_, $i, 1) = '';
  484.             }
  485.             elsif (!$repl &&
  486.               substr($_,$i,1) =~ /^[<>]$/) {
  487.             substr($_,$i,1) = 'b';
  488.             }
  489.         }
  490.         elsif ($c eq '[' && !$repl) {
  491.             $i++ if substr($_,$i,1) eq '^';
  492.             $i++ if substr($_,$i,1) eq ']';
  493.             $inbracket = 1;
  494.         }
  495.         elsif ($c eq ']') {
  496.             $inbracket = 0;
  497.         }
  498.         elsif ($c eq "\t") {
  499.             substr($_, $i, 1) = '\\t';
  500.             $i++;
  501.             $len++;
  502.         }
  503.         elsif (!$repl && index("()+",$c) >= 0) {
  504.             substr($_, $i, 0) = '\\';
  505.             $i++;
  506.             $len++;
  507.         }
  508.         }
  509.         &Die("Malformed substitution at line $.\n")
  510.           unless $end;
  511.         $pat = substr($_, 0, $repl + 1);
  512.         $repl = substr($_, $repl+1, $end-$repl-1);
  513.         $end = substr($_, $end + 1, 1000);
  514.         &simplify($pat);
  515.         $dol = '$';
  516.         $repl =~ s/\$/\\$/;
  517.         $repl =~ s'&'$&'g;
  518.         $repl =~ s/[\\]([0-9])/$dol$1/g;
  519.         $subst = "$pat$repl$delim";
  520.         $cmd = '';
  521.         while ($end) {
  522.         if ($end =~ s/^g//) {
  523.             $subst .= 'g';
  524.             next;
  525.         }
  526.         if ($end =~ s/^p//) {
  527.             $cmd .= ' && (print)';
  528.             next;
  529.         }
  530.         if ($end =~ s/^w[ \t]*//) {
  531.             $fh = &make_filehandle($end);
  532.             $cmd .= " && (print $fh \$_)";
  533.             $end = '';
  534.             next;
  535.         }
  536.         &Die("Unrecognized substitution command".
  537.           "($end) at line $.\n");
  538.         }
  539.         chop ($_ = &q(<<"EOT"));
  540. :    <<--#ifdef TSEEN
  541. :    $subst && \$tflag++$cmd;
  542. :    <<--#else
  543. :    $subst$cmd;
  544. :    <<--#endif
  545. EOT
  546.         next;
  547.     }
  548.  
  549.     if (/^p/) {
  550.         $_ = 'print;';
  551.         next;
  552.     }
  553.  
  554.     if (/^w/) {
  555.         s/^w[ \t]*//;
  556.         $fh = &make_filehandle($_);
  557.         $_ = "print $fh \$_;";
  558.         next;
  559.     }
  560.  
  561.     if (/^r/) {
  562.         $appendseen++;
  563.         s/^r[ \t]*//;
  564.         $file = $_;
  565.         $_ = "\$atext .= `cat $file 2>/dev/null`;";
  566.         next;
  567.     }
  568.  
  569.     if (/^P/) {
  570.         $_ = 'print $1 if /^(.*)/;';
  571.         next;
  572.     }
  573.  
  574.     if (/^D/) {
  575.         chop($_ = &q(<<'EOT'));
  576. :    s/^.*\n?//;
  577. :    redo LINE if $_;
  578. :    next LINE;
  579. EOT
  580.         $sawnext++;
  581.         next;
  582.     }
  583.  
  584.     if (/^N/) {
  585.         chop($_ = &q(<<'EOT'));
  586. :    $_ .= "\n";
  587. :    $len1 = length;
  588. :    $_ .= <>;
  589. :    chop if $len1 < length;
  590. :    <<--#ifdef TSEEN
  591. :    $tflag = 0;
  592. :    <<--#endif
  593. EOT
  594.         next;
  595.     }
  596.  
  597.     if (/^h/) {
  598.         $_ = '$hold = $_;';
  599.         next;
  600.     }
  601.  
  602.     if (/^H/) {
  603.         $_ = '$hold .= "\n"; $hold .= $_;';
  604.         next;
  605.     }
  606.  
  607.     if (/^g/) {
  608.         $_ = '$_ = $hold;';
  609.         next;
  610.     }
  611.  
  612.     if (/^G/) {
  613.         $_ = '$_ .= "\n"; $_ .= $hold;';
  614.         next;
  615.     }
  616.  
  617.     if (/^x/) {
  618.         $_ = '($_, $hold) = ($hold, $_);';
  619.         next;
  620.     }
  621.  
  622.     if (/^b$/) {
  623.         $_ = 'next LINE;';
  624.         $sawnext++;
  625.         next;
  626.     }
  627.  
  628.     if (/^b/) {
  629.         s/^b[ \t]*//;
  630.         $lab = &make_label($_);
  631.         if ($lab eq $toplabel) {
  632.         $_ = 'redo LINE;';
  633.         } else {
  634.         $_ = "goto $lab;";
  635.         }
  636.         next;
  637.     }
  638.  
  639.     if (/^t$/) {
  640.         $_ = 'next LINE if $tflag;';
  641.         $sawnext++;
  642.         $tseen++;
  643.         next;
  644.     }
  645.  
  646.     if (/^t/) {
  647.         s/^t[ \t]*//;
  648.         $lab = &make_label($_);
  649.         $_ = q/if ($tflag) {$tflag = 0; /;
  650.         if ($lab eq $toplabel) {
  651.         $_ .= 'redo LINE;}';
  652.         } else {
  653.         $_ .= "goto $lab;}";
  654.         }
  655.         $tseen++;
  656.         next;
  657.     }
  658.  
  659.     if (/^y/) {
  660.         s/abcdefghijklmnopqrstuvwxyz/a-z/g;
  661.         s/ABCDEFGHIJKLMNOPQRSTUVWXYZ/A-Z/g;
  662.         s/abcdef/a-f/g;
  663.         s/ABCDEF/A-F/g;
  664.         s/0123456789/0-9/g;
  665.         s/01234567/0-7/g;
  666.         $_ .= ';';
  667.     }
  668.  
  669.     if (/^=/) {
  670.         $_ = 'print $.;';
  671.         next;
  672.     }
  673.  
  674.     if (/^q/) {
  675.         chop($_ = &q(<<'EOT'));
  676. :    close(ARGV);
  677. :    @ARGV = ();
  678. :    next LINE;
  679. EOT
  680.         $sawnext++;
  681.         next;
  682.     }
  683.     } continue {
  684.     if ($space) {
  685.         s/^/$space/;
  686.         s/(\n)(.)/$1$space$2/g;
  687.     }
  688.     last;
  689.     }
  690.     $_;
  691. }
  692.  
  693. sub fetchpat {
  694.     local($outer) = @_;
  695.     local($addr) = $outer;
  696.     local($inbracket);
  697.     local($prefix,$delim,$ch);
  698.  
  699.     # Process pattern one potential delimiter at a time.
  700.  
  701.     DELIM: while (s#^([^\]+(|)[\\/]*)([]+(|)[\\/])##) {
  702.     $prefix = $1;
  703.     $delim = $2;
  704.     if ($delim eq '\\') {
  705.         s/(.)//;
  706.         $ch = $1;
  707.         $delim = '' if $ch =~ /^[(){}A-Za-mo-z]$/;
  708.         $ch = 'b' if $ch =~ /^[<>]$/;
  709.         $delim .= $ch;
  710.     }
  711.     elsif ($delim eq '[') {
  712.         $inbracket = 1;
  713.         s/^\^// && ($delim .= '^');
  714.         s/^]// && ($delim .= ']');
  715.     }
  716.     elsif ($delim eq ']') {
  717.         $inbracket = 0;
  718.     }
  719.     elsif ($inbracket || $delim ne $outer) {
  720.         $delim = '\\' . $delim;
  721.     }
  722.     $addr .= $prefix;
  723.     $addr .= $delim;
  724.     if ($delim eq $outer && !$inbracket) {
  725.         last DELIM;
  726.     }
  727.     }
  728.     $addr =~ s/\t/\\t/g;
  729.     &simplify($addr);
  730.     $addr;
  731. }
  732.  
  733. sub q {
  734.     local($string) = @_;
  735.     local($*) = 1;
  736.     $string =~ s/^:\t?//g;
  737.     $string;
  738. }
  739.  
  740. sub simplify {
  741.     $_[0] =~ s/_a-za-z0-9/\\w/ig;
  742.     $_[0] =~ s/a-z_a-z0-9/\\w/ig;
  743.     $_[0] =~ s/a-za-z_0-9/\\w/ig;
  744.     $_[0] =~ s/a-za-z0-9_/\\w/ig;
  745.     $_[0] =~ s/_0-9a-za-z/\\w/ig;
  746.     $_[0] =~ s/0-9_a-za-z/\\w/ig;
  747.     $_[0] =~ s/0-9a-z_a-z/\\w/ig;
  748.     $_[0] =~ s/0-9a-za-z_/\\w/ig;
  749.     $_[0] =~ s/\[\\w\]/\\w/g;
  750.     $_[0] =~ s/\[^\\w\]/\\W/g;
  751.     $_[0] =~ s/\[0-9\]/\\d/g;
  752.     $_[0] =~ s/\[^0-9\]/\\D/g;
  753.     $_[0] =~ s/\\d\\d\*/\\d+/g;
  754.     $_[0] =~ s/\\D\\D\*/\\D+/g;
  755.     $_[0] =~ s/\\w\\w\*/\\w+/g;
  756.     $_[0] =~ s/\\t\\t\*/\\t+/g;
  757.     $_[0] =~ s/(\[.[^]]*\])\1\*/$1+/g;
  758.     $_[0] =~ s/([\w\s!@#%^&-=,:;'"])\1\*/$1+/g;
  759. }
  760.  
  761. !NO!SUBS!
  762. chmod 755 s2p
  763. $eunicefix s2p
  764.